export default {
  template:[
    {name:"废灵根",odds:5,levelUpOdds:1,expSpeed:10,studySpeed:1},
    {name:"伪灵根",odds:4,levelUpOdds:10,expSpeed:20,studySpeed:2},
    {name:"真灵根",odds:3,levelUpOdds:20,expSpeed:40,studySpeed:3},
    {name:"异灵根",odds:2,levelUpOdds:30,expSpeed:60,studySpeed:4},
    {name:"天灵根",odds:1,levelUpOdds:40,expSpeed:80,studySpeed:5},
  ],

  generateFlair(){
    let template = this.template;
    let sum = 0;
    template.forEach((v) => {
      sum += v.odds
    });
    let rand = Math.floor(Math.random() * sum);
    let key = 0;
    let tem = 0;

    for (let i = 0; i < template.length; i++) {
      if (rand < template[i].odds + tem) {
        key = i;
        break;
      }
      tem += template[i].odds
    }

    return this.template[key];
  }
}
